package com.juyu.miliao.scheduler.config;

import static java.util.stream.Collectors.*;
import static java.util.Comparator.*;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.IntStream;

import com.juyu.miliao.common.dataSource.tool.distributeOperate.DistributeResultHandler;
import com.juyu.miliao.common.dataSource.tool.distributeOperate.DistributeResultHandlers;
import com.juyu.miliao.scheduler.domin.User;

public class GlobalDistributeResultHandlers implements DistributeResultHandlers {

	public DistributeResultHandler sortByUserIds(List<Integer> userIds){
		Map<Integer, Integer> map = IntStream.range(0, userIds.size()).boxed().collect(toMap(userIds::get, Function.identity()));
		return DistributeResultHandlers.appendCollection(comparing(obj -> map.get(((User)obj).getUserId())));
	}

	
}
